package com.play.ballen.home.adapter

import android.annotation.SuppressLint
import android.view.View
import android.widget.ImageView
import android.widget.TextView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.play.ballen.R
import com.play.ballen.home.entity.CommentX
import com.play.ballen.widget.emoji.FaceTextUtil
import com.yuven.appframework.util.imageloader.ImageUtil
import com.yuven.baselib.utils.ResourceUtil

class CommentList2Adapter(data: MutableList<CommentX>) :
    BaseQuickAdapter<CommentX, BaseViewHolder>(R.layout.comment_list_item2_layout, data) {
    init {
        addChildClickViewIds(R.id.huifu,R.id.zan_ly)
    }
    @SuppressLint("ResourceType")
    override fun convert(holder: BaseViewHolder, item: CommentX) {
        ImageUtil.instance.loadCircleImage(item.avatar_url, holder.getView(R.id.iv_head) , 0, 0)
        holder.setText(R.id.commentMember, item.nickname)
        holder.setText(R.id.message, FaceTextUtil.renderVideoComment(item.content,""))
        holder.setText(R.id.addTime, (item.post_time))
        holder.setText(R.id.zan_tv, item.like_count.toString())
        if(item.target_nickname.isEmpty()){
            holder.getView<ImageView>(R.id.sanjiao).visibility = View.GONE
            holder.getView<TextView>(R.id.commentMember2).visibility = View.GONE
        }else{
            holder.getView<ImageView>(R.id.sanjiao).visibility = View.VISIBLE
            holder.getView<TextView>(R.id.commentMember2).visibility = View.VISIBLE
            holder.setText(R.id.commentMember2, item.target_nickname)
        }

        if(item.like_count>0){
            holder.getView<TextView>(R.id.zan_tv).visibility = View.VISIBLE
        }else{
            holder.getView<TextView>(R.id.zan_tv).visibility = View.INVISIBLE
        }

        if(item.is_like){
            holder.getView<ImageView>(R.id.zan).background = ResourceUtil.getDrawable(R.drawable.zanle)
        }else{
            holder.getView<ImageView>(R.id.zan).background = ResourceUtil.getDrawable(R.drawable.zan)
        }
    }
}

